﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductCategory_List.aspx.cs"
    MasterPageFile="~/Admin/Admin.Master" Inherits="TimKen.Web.Admin.ProductCategory.ProductCategory_List" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentLinkAction" runat="server">
    <span class="action-span"><a href="ProductCategory_Add.aspx">
        <%=GetLangString("AddProductCategory")%></a></span>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentTitle" runat="server">
    <%=GetLangString("MenuProductCategory")%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" runat="server">
 
   <script type="text/javascript">
       var treeview;
       function flyTreeView_onInitialized(treeviewObject) {
           treeview = treeviewObject;

       }
       function HandleContextMenuPopup(sender, node, event) {
           var nodeContextMenuID = node.getContextMenuID();
           if (node.getContextMenuID().length == 0) return;

           var expandEnabled = node.getChildNodes().length > 0 && !node.getExpanded();
           var collapseEnabled = node.getChildNodes().length > 0 && node.getExpanded();
           var isLeaf = (node.getChildNodes().length <= 0 ? true : false);
           var isroot = (node.getLevel() == 0 ? true : false);
           var contextMenu = CFlyContextMenu.getInstanceById("<%=ContextMenuFolder.ClientID%>");
           var items = contextMenu.getItems();
           for (var i = 0; i < items.length; i++) {
               switch (items[i].getCommandName()) {
                   case "Expand":
                       items[i].setDisabled(!expandEnabled);
                       break;
                   case "Collapse":
                       items[i].setDisabled(!collapseEnabled);
                       break;
                   case "DelChildItem":
                       items[i].setDisabled(isroot);
                       break;
                   case "ProductManage":
                       items[i].setDisabled(isroot || !isLeaf);
                       break;
               }
           }
       }

       function ExpandNode(item, argument) {
           var node = argument;
           node.expand();
       }
       function CollapseNode(item, argument) {
           var node = argument;
           node.collapse();
       }

       function ModifyNode(item, argument) {
           var node = argument;
           document.URL = "ProductCategory_Add.aspx?Act=Edit&categoryId=" + node.getValue();
       }
     

       function DeleteNode(item, argument) {
           var node = argument;
           if (confirm("你确定删除分类【" + node.getText() + "】吗？")) {
               document.URL = "ProductCategory_List.aspx?Act=Delete&categoryId=" + node.getValue();

           }
       }

       function ProductManage(item, argument) {
           var node = argument;
           document.URL = "../Pattribute/CategoryOption_List.aspx?CategoryId=" + node.getValue();
       }
       
      </script>
    
    <NineRays:FlyTreeView ID="FlyTreeView1" runat="server" BackColor="White" ImageSet="MacOS"
                    BorderColor="Silver" BorderWidth="1px" Height="600px"    PostBackOnSelect="true"
        Width="100%" Padding="2px"      
                     SlideEffect="True"    ContextMenuID="ContextMenuFolder"    
        OnContextMenuJavascript="HandleContextMenuPopup"     OnInitializedJavascript="flyTreeView_onInitialized"
         >
                     <DefaultStyle Font-Names="Verdana" Font-Size="11px" ForeColor="Black" Padding="2px;4px;4px;2px"
                        RowHeight="18px" ImageUrl="$kde_folder" />
                    <SelectedStyle BackColor="68, 123, 205" BorderColor="150, 150, 150" BorderWidth="1px"
                        Padding="1px;3px;3px;1px" BorderStyle="Solid" ForeColor="White" />
                    <HoverStyle Font-Underline="True" />
                    <DataBindings>
                    <NineRays:FlyNodeBinding  TextField="CategoryName"   ValueField="CategoryID"  />
                    </DataBindings>
                </NineRays:FlyTreeView>
                
      <NineRays:FlyContextMenu ID="ContextMenuFolder" runat="server">
                    <Items>
                        <NineRays:FlyMenuItem Text="展开" Javascript="ExpandNode(item, argument);" CommandName="Expand" />
                        <NineRays:FlyMenuItem Text="收缩" Javascript="CollapseNode(item, argument);"
                            CommandName="Collapse" />
                            
                            <NineRays:FlyMenuItem CommandName="ModifyItem" 
                            Javascript="ModifyNode(item, argument);" Text="修改" />
                             <NineRays:FlyMenuItem Text="删除" Javascript="DeleteNode(item, argument);"   CommandName="DelChildItem" />
                             
                              <NineRays:FlyMenuItem CommandName="ProductManage" 
                            Javascript="ProductManage(item, argument);" Text="属性维护" />
                    </Items>
                </NineRays:FlyContextMenu>
 
</asp:Content>
